package cn.xinfei.xdecision.common.service.component.guiderule;

import cn.xinfei.xdecision.common.model.common.PageResult;
import cn.xinfei.xdecision.common.model.common.ResponseEntityDto;
import cn.xinfei.xdecision.common.model.common.requestParam.AssemblyRuleCodeReq;
import cn.xinfei.xdecision.common.model.common.requestParam.StatusParam;
import cn.xinfei.xdecision.common.model.component.guiderule.RuleVersion;
import cn.xinfei.xdecision.common.model.component.guiderule.vo.RuleVersionRespVo;
import cn.xinfei.xdecision.common.model.component.guiderule.vo.RuleVersionVo;
import cn.xinfei.xdecision.common.utils.enums.enginex.ComponentVersionStatusEnum;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;

public interface RuleVersionService extends IService<RuleVersion> {

	/**
	 * 校验是否存在【新建】版本，无则新建，有则更新
	 */
    Long checkAndAddVersion(RuleVersionVo version);

    Long addVersion(RuleVersionVo version);

    List<Long> addVersionList(List<RuleVersionVo> versionList);

    boolean updateVersion(RuleVersionVo version);

    boolean updateStatus(StatusParam statusParam);

    void lock(Long versionId);

    RuleVersionVo queryById(Long id);

    List<RuleVersion> getVersionByStatus(String ruleCode, int status);
    RuleVersion getVersionByVersionNo(String ruleCode, Long versionNo);

    List<RuleVersionVo> queryVersionListByRuleId(Long ruleId);

    List<RuleVersionVo> queryVersionInfoByRuleId(Long ruleId);

    /**
     * 通过规则code集合，查询版本集合
     *
     * @param ruleCodes 规则code
     * @param status    版本状态
     * @return {@link RuleVersion 版本}
     * @see ComponentVersionStatusEnum
     */
    List<RuleVersion> queryVersionByRuleCodes(List<String> ruleCodes, Integer status);

    List<RuleVersionVo> queryVersionInfoByRuleCode(String ruleCode);

    ResponseEntityDto<PageResult<List<RuleVersionRespVo>, RuleVersion>> listByRuleCode(AssemblyRuleCodeReq req);

    List<String> queryFieldEnByVersionId(Long versionId);
}
